package com.symaster.backups.enumerate;

import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author yinmiao
 * @version 2024/2/18
 */
@Getter
public enum PathType {
    FILE(1, "文件"),
    FOLDER(2, "文件夹");

    private final int code;
    private final String label;
    private static final Map<Integer, PathType> byCode;

    static {
        byCode = Arrays.stream(PathType.values()).collect(Collectors.toMap(PathType::getCode, e -> e));
    }

    PathType(int code, String label) {
        this.code = code;
        this.label = label;
    }

    public static PathType ofCode(int code) {
        return byCode.get(code);
    }
}
